package com.qq.controller;

import com.qq.dto.ActionResult;
import com.qq.pojo.Car;
import com.qq.service.CarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;

@RestController
public class CarController {

    @Autowired(required = false)
    private CarService carService;

    @RequestMapping(value = "/selectCarById",method = RequestMethod.GET)
    @ResponseBody
    public ActionResult selectCarById(int cid){
        //System.out.println(id);
        Car car = carService.selectCarById(cid);
        ActionResult actionResult = new ActionResult(200, null, car);
        return actionResult;
    }
    /**
     * 根据租金排序
     */
    @GetMapping("/getAllCarsDESC")
    public HashMap<String,Object> getAllCarsDESC(){
        List<Car> list = carService.getAllCarsDESC();
        HashMap<String,Object> map = new HashMap<>();
        map.put("code",0);
        map.put("count",1000);
        map.put("msg","");
        map.put("data",list);
        return map;
    }
//    /**
//     * 根据热度排序
//     */
//    @GetMapping("/getAllCarsASC")
//    public HashMap<String,Object> getAllCarsASC(){
//        List<Car> list = carService.getAllCarsASC();
//        HashMap<String,Object> map = new HashMap<>();
//        map.put("code",0);
//        map.put("count",1000);
//        map.put("msg","");
//        map.put("data",list);
//        return map;
//    }
    /**
     *  根据热度排序
     */
    @RequestMapping(value = "/getCarsByNum", method = RequestMethod.GET)
    public HashMap<String, Object> getCarsByNum(){
        List<Car> list = carService.getCarsByNum();
        HashMap<String, Object> map = new HashMap<>();
        map.put("code",0);
        map.put("count",1000);
        map.put("msg","");
        map.put("data",list);
        return map;
    }

}
